package org.example.demo3.service;
import org.apache.ibatis.annotations.Param;
import org.example.demo3.info.*;
import org.example.demo3.mapper.*;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class Articleservice {
    @Resource
    private Articlemapper articlemapper;
    public List<Articleinfo> getarticle(Userinfo userinfo){
        return articlemapper.getarticle(userinfo);
    }
    public Integer delete(Integer id){
        String type=articlemapper.select_type_byid(id);
        articlemapper.delete_type_count(type);
        articlemapper.delete_type();
        return articlemapper.delete(id);
    }
    public Articleinfo_plus getarticlecontent(Integer id){
        return articlemapper.getarticlecontent(id);
    }
    public Integer rcount(Integer id){
        return articlemapper.rcount(id);
    }
    public Integer edit_article(Articleinfo articleinfo){
        return articlemapper.edit_article(articleinfo);
    }
    public Integer add_article(Articleinfo articleinfo,int userid){
        if (articleinfo.getType().equals("")){
            articleinfo.setType(null);
        }else {
            articlemapper.add_type(articleinfo.getType(),userid);
        }
        return articlemapper.add_article(articleinfo);
    }
    public Integer allpage(){
        return articlemapper.allpage();
    }
    public List<Articleinfo_plus> this_page_content(int index, int page){
        return articlemapper.this_page_content(index,page);
    }
    public Userinfo author(int uid){
        return articlemapper.author(uid);
    }
    public Integer setresponse(Responseinfo responseinfo){
        return articlemapper.setresponse(responseinfo);
    }
    public List<Responseinfo> getresponse(Integer reviewid){
        return articlemapper.getresponse(reviewid);
    }
    public Integer setreview(Reviewinfo reviewinfo){
        return articlemapper.setreview(reviewinfo);
    }
    public List<Reviewinfo> getreview(Integer blogid){
        return articlemapper.getreview(blogid);
    }
    public Integer deletereview(Integer id){
        return articlemapper.deletereview(id);
    }
    public Integer deletereview_response(Integer id){
        return articlemapper.deletereview_response(id);
    }
    public Integer deleteresponse(Integer id){
        return articlemapper.deleteresponse(id);
    }
    public List<Responseinfo> get_response_res(Responseinfo responseinfo){
        return articlemapper.get_response_res(responseinfo);
    }
    public int setresponse_res(Responseinfo responseinfo){
        return articlemapper.setresponse_res(responseinfo);
    }
    public List<String> type_content(int userid){
        return articlemapper.type_content(userid);
    }
    public List<Articleinfo> getarticle_by_type(int id,String type){
        return articlemapper.getarticle_by_type(id,type);
    }
}
